/**
 ** 图片本地预览
 **/
define(['underscore'],
    function(_) {
        function Preview() {
            var self = this;
            self.$el = $('#preview-page')
            self.init=function () {
                self.render();
            }
            self.render=function () {
                var previewImgSrcs = window.localStorage.getItem('previewImgSrcs');
                if(previewImgSrcs){
                    var tpl = _.template($('#t-preview-demo2').text())({imgs:JSON.parse(previewImgSrcs)});
                    self.$el.html(tpl);
                    $('.preview-image-frame img').each(function () {
                        if (($(this)[0].naturalWidth > 0) && ($(this)[0].naturalWidth == $(this)[0].naturalHeight)) {
                            $(this).width(167)
                        }
                    });
                }else{
                    self.$el.html('<h2>没有图片可以预览!</h2>');
                }

            }
        }

        return new Preview();
    });
